|
|
|
| Table 4.8 Standard Windows Fonts |  |
|
|
|
|
|
|
Programming with CreateFont |
|
|
|
|
|
|
|
|
Once you have used CreateFont to obtain a logical font handle, you can select that font into a form, picture box, or printer using the SelectObject function. This function returns the handle of the font that was previously in use. When you are done using the new font, you should reselect the original font using SelectObject. Then delete the font you created, using the DeleteObject function to free system resources. |
|
|
|
|
|
|
|
|
The following code shows how you would write text at a -45 degree angle starting at the upper-left corner of a form. |
|
|
|
 |
|
|
|
|
Private Sub Form_Load()
Const txt = "This text is written at a -45 degree angle."
Dim newfont As Long
Dim oldfont As Long
AutoRedraw = True
' Create the logical font. newfont = CreateFont(20, 0, -450, 0, _
FW_NORMAL, False, False, False, _
ANSI_CHARSET, OUT_DEFAULT_PRECIS, _
CLIP_CHARACTER_PRECIS, PROOF_QUALITY, _
VARIABLE_PITCH Or FF_ROMAN Or 4, _
"TimesNewRoman")
' Select the new font. oldfont = SelectObject(hdc, newfont) |
|
|
|
|
|